import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
// import music from './music'
export default new Vuex.Store({
  state: {
    // 登录框显示
    isLoginShow:false,
    tishi:{
      val:'',
      show:false
    },
    // 音乐id
    musicId:0,
    musicli:[],
    // 当前项
    musicindex:-1,
    // 歌单
    songlist:[],
  },
  getters: {
  },
  mutations: {
    changeTishi(state,payload){
      state.tishi.show = true
      state.tishi.val = payload
    },
    clsTishi(state){
      state.tishi.show = false
    },
    changeMusicId(state,payload){
      state.musicId = payload
    },
    pushMusicLi(state,payload){
      state.musicli.forEach((item,i)=>{
        if (item == payload.id) {
          state.musicli.splice(i,1)
        }
      })
      state.musicli.push(payload.id)
      state.musicindex = payload.index
    },
    changeSongList(state,payload){
      state.songlist = payload
    }
  },
  actions: {
    activetionTishi({commit},payload){
      commit('changeTishi',payload);
      setTimeout(() => {
        commit('clsTishi')
      }, 2000);
    }
  },
  modules: {
    // music
  }
})
